<%@ Page Language="C#" MasterPageFile="~/SolaraNoLeftMenu.Master" AutoEventWireup="true" CodeBehind="SalesOrderEdit.aspx.cs" Inherits="WebDesktop.Pages.Sales.SalesOrderEdit" %>

<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
 <table border="0" style="width: 850px">
  <tr>
    <td colspan="4" class="SalesOrderClass" style="height: 16px">Sales Orders/ 
        <asp:Label ID="lblSalesOrderClass" runat="server"  Text="Label"></asp:Label></td>
    <td width="113" class="ColumnsHeaders" style="height: 16px">Date</td>
    <td colspan="2" width="154" class="ColumnsHeaders" style="height: 16px">S.O No.</td>
  </tr>
  <tr>
    <td style="height: 26px; width: 273px;" colspan="2">&nbsp;&nbsp;</td>
    <td colspan="2" align="center" style="height: 26px"><asp:Button ID="btn_OrderUpdate" runat="server" Text="Update" OnClick="btn_OrderUpdate_Click" /></td>
    <td class="StaticData" style="height: 26px"><asp:Label ID="lblSalesOrderDate" runat="server"  Text="Label"></asp:Label>&nbsp;</td>
    <td colspan="2" class="StaticData" style="height: 26px"><asp:Label ID="lblSalesOrderNumber" runat="server"  Text="Label"></asp:Label>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" class="ColumnsHeaders" style="height: 14px; width: 273px;">Bill To </td>
    <td colspan="2" style="height: 14px">&nbsp;</td>
    <td colspan="3" class="ColumnsHeaders" style="height: 14px">Job Address </td>
  </tr>
  <tr>
    <td colspan="2" rowspan="3" class="StaticData" style="width: 273px">
        <asp:TextBox ID="txtCustomer" runat="server"  Enabled="False"
             TextMode="MultiLine" Width="100%"></asp:TextBox></td>
    <td colspan="2">&nbsp;<rad:radcombobox id="RadComboBox1" runat="server" enableloadondemand="True"
            onitemsrequested="RadComboBox1_ItemsRequested" showmoreresultsbox="True" skinspath="~/RadControls/ComboBox/Skins"
            width="150px"></rad:radcombobox></td>
    <td colspan="3" rowspan="3" class="StaticData">
        <asp:TextBox ID="txtJobAddress" runat="server"  Enabled="False"
             TextMode="MultiLine" Width="100%"></asp:TextBox></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" style="width: 273px">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" class="ColumnsHeaders" style="width: 273px">Order Status</td>
    <td width="110" class="ColumnsHeaders">&nbsp;Rep.</td>
    <td width="175" class="ColumnsHeaders" style="width: 177px">Weeks in Production </td>
    <td class="ColumnsHeaders">P.O Number</td>
    <td class="ColumnsHeaders" style="width: 190px">Projected Ship Day </td>       
    <td class="ColumnsHeaders">
        Mexico Projected&nbsp; Day</td>
  </tr>
  <tr>
    <td colspan="2" class="Grid" style="width: 273px">
        <asp:Label ID="lblOrderStatus" runat="server" Text="Label" Visible="false"></asp:Label>
        <asp:DropDownList ID="ddOrderStatus" 
                          runat="server" 
                          Width="100%"
                          AppendDataBoundItems="True" DataSourceID="StatusDataSource" 
                          DataTextField="Name" 
                          DataValueField="ID"                                                     
        >
        <asp:ListItem Selected="True" Text="Select One" Value="-1"></asp:ListItem>
        </asp:DropDownList>
    </td>
    <td class="StaticData">&nbsp;<asp:Label ID="lblSalesRep" runat="server"></asp:Label></td>
    <td class="StaticData" style="width: 177px"><asp:Label ID="lblDaysInProduction" runat="server"  Text="Label"></asp:Label>&nbsp;</td>
    <td class="StaticData"><asp:Label ID="lblPONumber" runat="server"  Text="Label"></asp:Label>
    </td>
    <td class="StaticData" style="width: 190px"><asp:TextBox ID="txtProjectedShipDay" runat="server" CssClass="StaticFont"></asp:TextBox></td>
      <td class="StaticData"><asp:TextBox ID="txtProductionShipDay" runat="server" CssClass="StaticFont" OnTextChanged="txtProductionShipDay_TextChanged"></asp:TextBox></td>
  </tr>
  <tr>
    <td colspan="7">
        <div id ="GridContenHolder" class="ItemsContentHolder" style="width: 100%; height: 149px;">
            <asp:GridView ID="GridView1" runat="server"            
             AutoGenerateColumns="False"             
             HeaderStyle-ForeColor="Black"
             HeaderStyle-BackColor="#9999ff"
             HeaderStyle-HorizontalAlign="center"
             BackColor="White"
             BorderColor="#E7E7FF"
             BorderStyle="None"
             BorderWidth="1px"
             CellPadding="3"
             GridLines="Horizontal"              
             RowStyle-BorderColor="black" Width="100%"          
             >
             <Columns>
                <asp:TemplateField HeaderText="Sku" SortExpression="ID">
                    <ItemTemplate>  
                        <asp:HyperLink ID="HyperLink1" 
                                       runat="server"
                                       ToolTip='<%# Bind("ID") %>'
                                       Text='<%# Bind("Sku") %>' 
                                       OnDataBinding="HyperLink1_DataBinding"                                       
                                        >
                        </asp:HyperLink>                                      
                    </ItemTemplate>

                </asp:TemplateField>                                                                
                <asp:BoundField DataField="Description" HeaderText="Description" ReadOnly="True"/>
                <asp:BoundField DataField="Quantity" HeaderText="Qty" ReadOnly="True"/>
                <asp:BoundField DataField="Status" HeaderText="Status" ReadOnly="True"/>
             </Columns>
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" BorderColor="Black" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="#F7F7F7" ForeColor="Black"  />            
            </asp:GridView>
        </div>
    </td>
      <td colspan="1">
      </td>
  </tr>
  <tr>
    <td colspan="6">
        <div>
        </div>        
    </td>
      <td colspan="1">
      </td>
  </tr>
  <tr>
    <td colspan="7">
        <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
            <cc1:TabPanel ID="TabPanel_Comments" runat="server" HeaderText="Comments">
                 <ContentTemplate>
                       <asp:GridView ID="CommentsGrid"                         
                        Width="750px" 
                        runat="server"
                        CssClass="Grid" 
                        DataSourceID="SqlDataSource1"             
                        AutoGenerateColumns="False" 
                        CellPadding="4" 
                        ForeColor="#333333" 
                        GridLines="Horizontal"                        
                        ShowFooter="True" 
                        OnRowCommand="CommentsGrid_RowCommand" 
                        OnRowDataBound="CommentsGrid_RowDataBound"
                        EnableViewState="False"
                        >
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <EditRowStyle BackColor="#999999" />                        
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />                        
                        <Columns>
                            <asp:TemplateField HeaderText="Comments">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comment") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" />
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Comment") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>                                    
                                    <asp:TextBox ID="NewComment" 
                                                 runat="server" 
                                                 CssClass="Grid"
                                                 Width="625px">
                                     </asp:TextBox>                                                         
                                </FooterTemplate>                                
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Posted By">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    &nbsp;
                                </FooterTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Posted">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Date_Posted") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Date_Posted", "{0:MM/dd/yyyy}") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>                                
                                    <asp:Button ID="Button1" runat="server" 
                                                CssClass="Grid" 
                                                Text="Add"
                                                CommandName="Insert"  
                                                />
                                </FooterTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Assign_To"  HeaderText="Assigned To" ReadOnly="True" />
                        </Columns>                        
                    </asp:GridView>
                </ContentTemplate>
            </cc1:TabPanel>
            <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Red Flag" >
                <ContentTemplate>
                    <div>
                        <table width="100%" class="Grid">
                            <tr>
                                <td width="81" valign="top" align="right">
                                    Assign To:</td>
                                <td valign="top" style="width: 441px">
                                    <asp:DropDownList ID="ddUserList" 
                                                      runat="server" 
                                                      CssClass="Grid"
                                                      AppendDataBoundItems="True" >
                                        <asp:ListItem Selected="True" Text="Select one" Value="-1" />
                                    </asp:DropDownList>
                                </td>
                                <td valign="top">
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 81px" align="right">
                                    Message:</td>
                                <td rowspan="3" style="width: 441px">
                                    <asp:TextBox ID="txtRedFlagMessage" runat="server" MaxLength="150" TextMode="MultiLine" Width="100%"></asp:TextBox></td>
                                <td align="center" rowspan="3" valign="middle">
                                    Assign the task to a user before adding the red flag to the order.</td>
                            </tr>
                            <tr>
                                <td style="width: 81px">&nbsp;</td>
                            </tr>                            
                            <tr>
                                <td style="width: 81px">&nbsp;</td>
                            </tr>
                            <tr>
                                <td style="width: 81px">&nbsp;</td>
                                <td style="width: 441px" class="Grid">
                                    <asp:Button ID="btnSetRedFlag" runat="server" CssClass="Grid" OnClick="btnSetRedFlag_Click"
                                        Text="Add" />
                                    <input id="Reset1" class="Grid" type="reset" value="Clear" /></td>
                                <td class="Grid">
                                </td>
                            </tr>                                                        
                            <tr>
                                <td style="width: 81px">
                                </td>
                                <td class="Grid" style="width: 441px">
                                </td>
                                <td class="Grid">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3" class="ColumnHeaders">
                                    Current Red Flags</td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <asp:GridView ID="GridView2" DataKeyNames="PK_ID" runat="server" BackColor="White" BorderColor="#E7E7FF"
                                        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" CssClass="Grid" DataSourceID="ObjectDataSource_RedFlag" OnRowDeleting="GridView2_RowDeleting" Width="100%" OnRowDeleted="GridView2_RowDeleted">
                                        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                                        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                                        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                                        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                                        <AlternatingRowStyle BackColor="#F7F7F7" />
                                        <Columns>
                                            <asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" />
                                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                            <asp:BoundField DataField="Assign_To" HeaderText="Assign_To" SortExpression="Assign_To" />
                                            <asp:BoundField DataField="Date_Posted" HeaderText="Date_Posted" SortExpression="Date_Posted" />
                                        </Columns>
                                    </asp:GridView>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 81px">
                                </td>
                                <td class="Grid" style="width: 441px">
                                </td>
                                <td class="Grid">
                                </td>
                            </tr>
                        </table>
                    </div>
                </ContentTemplate>
            </cc1:TabPanel>
            
            <cc1:TabPanel ID="TabPanel_OrdersLog" HeaderText="Order Log" runat="server">
                <ContentTemplate>
                       <asp:GridView ID="OrdersLogGrid" runat="server"
                                     EnableViewState="False" 
                                     AutoGenerateColumns="False" 
                                     BackColor="LightGoldenrodYellow" 
                                     BorderColor="Tan" BorderWidth="1px" 
                                     CellPadding="2" 
                                     DataSourceID="SqlDataSource_LogEntry" 
                                     ForeColor="Black" 
                                     GridLines= "Horizontal"
                                     Width="100%"
                                     CssClass="Grid" >
                           <FooterStyle BackColor="Tan" />
                           <Columns>
                               <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
                               <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
                               <asp:BoundField DataField="DatePosted" HeaderText="DatePosted" SortExpression="DatePosted" />
                           </Columns>
                           <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                           <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                           <HeaderStyle BackColor="Tan" Font-Bold="True" />
                           <AlternatingRowStyle BackColor="PaleGoldenrod" />
                       </asp:GridView>
                </ContentTemplate>
            </cc1:TabPanel>
            <cc1:TabPanel ID="TabPanel_ItemsLog" HeaderText="Items Log" runat="server" >
                <ContentTemplate>
                       <asp:GridView ID="ItemsLogGrid" runat="server"
                                     EnableViewState="False" 
                                     AutoGenerateColumns="False" 
                                     BackColor="LightGoldenrodYellow" 
                                     BorderColor="Tan" BorderWidth="1px" 
                                     CellPadding="2" 
                                     DataSourceID="SqlDataSource_ItemLogEntry" 
                                     ForeColor="Black" 
                                     GridLines= "Horizontal"
                                     Width="100%"
                                     CssClass="Grid" >
                           <FooterStyle BackColor="Tan" />
                           <Columns>
                               <asp:BoundField DataField="ItemStatus" HeaderText="Status" SortExpression="Status" />
                               <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
                               <asp:BoundField DataField="DatePosted" HeaderText="DatePosted" SortExpression="DatePosted" />
                           </Columns>
                           <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                           <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                           <HeaderStyle BackColor="Tan" Font-Bold="True" />
                           <AlternatingRowStyle BackColor="PaleGoldenrod" />
                       </asp:GridView>
                </ContentTemplate>
            </cc1:TabPanel>            
        </cc1:TabContainer>
      </td>    
      <td colspan="1">
      </td>
  </tr>
</table>
<!------------------------------------------ Comments Grid  ------------------------------------------------------//--> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>"
        SelectCommand="SalesOrderComments_GetCommentBySalesOrderID" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:QueryStringParameter Name="SalesOrderID" QueryStringField="cde" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br/>
<!-----------------------------------------------------------------------------------------------------------//-->
<!------------------------------------------ Status ComboBox -----------------------------------------------//-->
    <asp:ObjectDataSource
        ID="StatusDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="StatusList" TypeName="Xeneize.SolaraBL.User" OnObjectCreating="StatusDataSource_ObjectCreating">
    </asp:ObjectDataSource>
    <asp:SqlDataSource ID="SqlDataSource_LogEntry" runat="server" ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>"
        SelectCommand="SalesOrderStatusTransactionLog_GetLogBySalesOrderId" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="lblSalesOrderNumber" Name="SalesOrderId" PropertyName="Text"
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource_ItemLogEntry" runat="server" ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>"
        SelectCommand="SalesOrderItemStatusTransactionLog_GetLogBySalesOrderId" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="lblSalesOrderNumber" Name="SalesOrderId" PropertyName="Text"
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource_RedFlag" runat="server" ConnectionString="<%$ ConnectionStrings:SolaraConnectionString %>"
        SelectCommand="SalesOrderComments_GetRedFlagBySalesOrderID" SelectCommandType="StoredProcedure" DeleteCommand="SalesOrderComments_DeleteRedFlag" DeleteCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="lblSalesOrderNumber" Name="SalesOrderID" PropertyName="Text"
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="PK_ID" Type="Int32"  />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource_RedFlag" runat="server" OldValuesParameterFormatString="{0}"
        SelectMethod="GetSalesOrderRedFlag" TypeName="Xeneize.SolaraBL.SalesOrder" DeleteMethod="DeleteRedFlag">
        <SelectParameters>
            <asp:ControlParameter ControlID="lblSalesOrderNumber" Name="SalesOrderId" PropertyName="Text"
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="PK_ID" Type="Int32" />
        </DeleteParameters>
    </asp:ObjectDataSource>
<!-----------------------------------------------------------------------------------------------------------//-->
</asp:Content>
